@extends('admin.layout.layout')
@section('title','订单显示')
@section('con')
        <div id="page-wrapper">
            <div class="row">
                <div ass="col-lg-12">
                    <h1 class="page-header">
                   @section('head')     
                    订单列表
                    @show


                    </h1>
                </div>
                <!-- /.col-lg-12 -->
            </div>
            <!-- /.row -->
            
            <div class="row">
                <div class="col-lg-12">
                    <div class="panel panel-default">
                        <div class="panel-heading">
                            订单显示
                        </div>
                        <!-- /.panel-heading -->
                        
                        <div class="panel-body">
                            <div class="dataTable_wrapper">
                                 <div id="dataTables-example_wrapper" class="dataTables_wrapper form-inline dt-bootstrap no-footer">
                                    <div class="row">
                        <form action="{{url('/admin/good/index')}}" method='get'>
                                <div class="col-sm-6">
                                            <div class="dataTables_length" id="dataTables-example_length">
                                
                                                <label>每页显示 
                                                    <select name="num" aria-controls="dataTables-example" class="form-control input-sm">
                                                        <option value="1" @if(!empty($lists['num']) && $lists['num'] == 1 ){ selected } @endif>1</option>
                                                        <option value="3" @if(!empty($lists['num']) && $lists['num'] == 3 ){ selected } @endif>3</option>
                                                        <option value="50" @if(!empty($lists['num']) && $lists['num'] == 50 ){ selected } @endif>50</option>
                                                        <option value="100" @if(!empty($lists['num']) && $lists['num'] == 100 ){ selected } @endif>100</option>
                                                    </select> 
                                                条</label>
                                            </div>
                                        </div>
                             <div class="col-sm-6">
                                <div id="dataTables-example_filter" class="dataTables_filter">
                                    <label>查询:
                                        <input type="search" value='{{$lists["keyword"]}}'  class="form-control input-sm" name="keyword" aria-controls="dataTables-example">
                                    </label>
                                    <button class="btn btn-success" >查询</button>
                                </div>
                            </div>
                        </div>
                        </form>
                                <div class="row"><div class="col-sm-12"><table id="dataTables-example" class="table table-striped table-bordered table-hover dataTable no-footer" role="grid" aria-describedby="dataTables-example_info">
                                    <thead>
                                        <tr role="row">
                                        <th>订单id</th>
                                        <th>金额</th>
                                        <th>下单人</th>
                                        <th>订单状态</th>
                                        <th>留言</th>
                                        <th>下单时间</th>                                        
                                        <th>操作</th>
                                        </tr>
                                    </thead>
                                    <tbody>
                                                                        
                                            @foreach($goods as $k=>$v)
                                    <tr class="gradeA odd" role="row">
                                            <td class="sorting_1">{{$v->gid}}</td>
                                            <td >{{$v->gname}}</td>
                                            <td >{{$v->gname}}</td>
                                            <td >{{$v->gname}}</td>
                                            <td >{{$v->gname}}</td>
                                            <td >{{$v->gname}}</td>
                                            <td class="center"><a href="{{url('/admin/good/edit?gid='.$v->gid)}}">修改</a>
                                               
                                                    
                                                    <button class='sta' @if($v->status==2) { disabled } @endif status=2 >下架</button>
                                                    <button class='sta' @if($v->status==3) { disabled } @endif status=3 >特殊</button>
                                               
                                                    
                                                    <button  class='sta' @if($v->status==1) { disabled } @endif  status=1 >上架</button>
                                                    
                                               


                                            </td>
                                        
                                        
                                        </tr>
                                            @endforeach
                                   

                                        </tbody>
                                </table>
                                </div>
                                
                                    {!! $goods->appends($lists)->render() !!}
                                </div>

                            <!-- /.table-responsive -->
                            
                        </div>
                        <!-- /.panel-body -->
                    </div>
                    <!-- /.panel -->
                </div>
          
            <!-- /.row -->
           
            <!-- /.row -->
        </div>
 @endsection

 @section('js')
<script type="text/javascript">
    
    $.ajaxSetup({
        headers: {
            'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content')
        }
});
        //获取删除标签
         var btn = $('.delete-btn');
         btn.click(function()
         {
            //获取当前的id
            var id =$(this).parents('tr').find('.sorting_1').html();
            //发送ajax
            // alert(uid);
            var opp = $(this);
           $.post('/admin/good/delete',{gid:id},function(data){

                // console.log(data);
                 if(data==1){
                     alert('删除成功');
                     opp.parents('tr').remove();

                
                 }else{
                     alert('删除失败');
                 }
           });
         // alert(id);
         // return false;
         }) 

    //状态修改处理
        //进行判断
        
        
        //获取按钮
       var sta= $('.sta');
        //获取按钮的
       sta.click(function()
       {

        
        $(this).parent().find('.sta').removeAttr('disabled');
          //获取id
          var id = $(this).parents('tr').find('.sorting_1').html();
          // console.log(id);
          var op = $(this);
          var word = op.html();
         
          // alert(word);
          //获取属性
          var value = op.attr('status');
          //发送ajax
          $.get('/admin/good/status',{gid:id,sta:value},function(data)
          {

           
                if(data)
                {
                    alert('状态修改成功');

                    // op.parents('tr').find('.sa').empty();
                     op.parents('tr').find('.sa').html(word);
                    //进行判断
                    op.attr('disabled','disabled');

                    // alert(a);
                }else{
                    alert('状态修改失败');
                }
          },'json')
       })
</script>
 @endsection
                      